<?php
/**
 * Created by PhpStorm.
 * User: jksen
 * Date: 2018/1/18
 * Time: 下午2:52
 */

namespace app\admin\controller\v1;

use think\Request;
use app\common\Validate\WidgetActionValidate;

class WidgetAction
{
    private $arr;

    /**
     * Api constructor.
     * @param $array
     */
    public function __construct($array)
    {
        $this->arr = $array;
    }


    public function addAction()
    {
        $model = model('app\common\model\WidgetAction');
        $model->option_name = 'targets';
        $model->option_code = 'target';
        $model->option_value = '';

        $validate = validate('WidgetActionValidate');
        if ($validate->scene('add')->check($model)) {
            $model->save();
            return $model->getLastInsID();
        }
        return $validate->getError();
    }
}